#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
    struct stat buf;
    char *ptr;


    if (lstat("/root/helloworld", &buf) < 0) {
        printf("lstat error\n");
        exit(EXIT_FAILURE);
    }

    if (S_ISREG(buf.st_mode))
        ptr = "regular";
    if (S_ISBLK(buf.st_mode))
        ptr = "block special";
    if (S_ISSOCK(buf.st_mode))
        ptr = "socket";

    printf("type: %s\n", ptr);


    return EXIT_SUCCESS;
}
